package mailcommon.entities;

import java.io.Serializable;
import java.util.*;

public class Folder implements Serializable {

    private String name;
    private String address;
    private ArrayList<Integer> lettersId;

    public Folder() {
    }

    public Folder(String address, String name) {
        this.address = address;
        this.name = name;
    }

    public ArrayList<Integer> getLettersId() {
        return (ArrayList<Integer>) lettersId.clone();
    }

    public void addLetter(int letterId) {
        lettersId.add(letterId);
    }

    public void removeLetter(int letterId) {
        Iterator<Integer> iterator = lettersId.iterator();
        while (iterator.hasNext()) {
            if (iterator.next().compareTo(letterId) == 0) {
                iterator.remove();
            }
        }
    }

    public void rename(String newName) {
        name = newName;
    }

    public String getName() {
        return name;
    }

    public String getAddress() {
        return address;
    }
}
